﻿namespace TradeHelp.MaterializedObjectViews
{
    /// <summary>
    /// Callback that defines client code that must support handling
    /// of incremental message bursts.  ViewMsgBursts should alwayse
    /// by sequencable, meaning that the burst provides an indication
    /// of the initial burst and a sequence number.  All messages
    /// can be resequenced in terms of ists sequence number.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="burst"></param>
    public delegate void StreamMessageDelegate<T>(ViewMessageBurst<T> burst);

    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IViewStream<T>
    {
        /// <summary>
        /// Request to stream data after creation.  All incremental updates are
        /// provided to the callback.  StreamData can have the additional side effect
        /// of instructing the stream to initialize and begin streaming to itself.
        /// </summary>
        /// <param name="callback">delegate to handle incremental data message bursts</param>
        void StreamData(StreamMessageDelegate<T> callback);

        /// <summary>
        /// Request to unsubscribe client code from recieving further incremental updates
        /// </summary>
        /// <param name="callback"></param>
        void Unsubscribe(StreamMessageDelegate<T> callback);        
    }
}